<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://cdn.bootcss.com/jquery/3.0.0-beta1/jquery.js"></script>
</head>
<body>
	<h2>Hello World! 哈哈</h2>
	<form id="form">
		<input name="data.a" value="123" /> <input name="data.b" vaue="true" />
	</form>
	<script type="text/javascript">
		function commonAjax(data, url, callBack) {
			$.ajax({
				contentType : 'application/json',
				url : url,
				data : data,
				type : 'POST',
				success : function(response) {
					if (response.stateCode == '0') {
						callBack(response);//请求成功,就调用后续方法
					} else {
						alert(response.exception.message);//请求失败,用前端框架输出错误信息
					}
				},
				fail : function(response) {
					alert(response.exception.message);
				}
			});
		}

		var data = $('#form').serialize();
		var context = {
			data : {
				aName : {
					age : 99,
					id : {
						id : 66,
						name : 'id'
					},
					b : 199
				}
			}
		};
		var dataStr = JSON.stringify(context);

		// 		commonAjax(dataStr, 'test15', function(data) {
		// 			alert('请求成功');
		// 			console.log(data.data);
		// 		});
		$.ajax({
			contentType : 'application/json',
			url : 'test24',
			type : 'POST',
			success : function(data) {
				data = $.parseJSON(data);
				alert(data.a);
			}
		});
	</script>
</body>
</html>
